<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0"
          xmlns:ui="http://java.sun.com/jsf/facelets"
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:f="http://java.sun.com/jsf/core">

<ui:composition xmlns="http://www.w3.org/1999/xhtml">
<f:subview id="commentBodyView">
<f:loadBundle basename="kuzmenkov.oip.i18n.front.commentRes" var="commentBundle"/>

<div class="pageTitle">
    <h:outputText value="#{commentBundle.pageTitle}"/>
</div>

<h:panelGroup rendered="#{commentController.isError}">
    <div class="pageError">
        <h:outputText value="#{commentController.error}"/>
    </div>
</h:panelGroup>

<h:panelGroup rendered="#{!moduleChoosingController.selectedModule}"
        styleClass="pageMessage">
    <h:form>
        <h:outputText value="#{commentBundle.selectModule1} "/>
        <h:commandLink value=" #{commentBundle.selectModule2}" action="home"/>
    </h:form>
</h:panelGroup>

<h:panelGroup rendered="#{moduleChoosingController.selectedModule}">
<div class="mainPanel">

<div class="mainPanelTitle">
    <h:outputText value="#{commentController.moduleName}"/>
</div>
<div class="mainPanelContent">
    <!--for each a comment-->
    <ui:repeat value="#{commentController.comments}" var="comment">


        <div class="comment">
            <div class="commentHead">
                <div class="commentUserName">
                    <h:outputLink
                            styleClass="commentUserName"
                            value="mailto:#{comment.email}">
                        <h:outputText value="#{comment.userName}"/>
                    </h:outputLink>
                    <!--didn't work i18n ?Subject=#!{commentBundle.mailSubjectBeg} '#!{commentController.moduleName}'-->
                </div>
                <div class="commentSendingDate">
                    <h:outputText value="#{comment.sendingDate}"/>
                </div>
            </div>
            <pre class="commentMessage">
                <h:outputText value="#{comment.message}"/>
            </pre>
        </div>
    </ui:repeat>

    <div class="commentChunkingLine" id="chunkLine">
        <h:form>
            <ui:repeat value="#{commentController.chunks}" var="chunk">
                <h:commandLink
                        styleClass="#{((chunk.number - 1) == commentController.chunkIndex)?'commentCurrentChunkLink':'commentChunkLink'}"
                        value="#{chunk.number}"
                        action="comments"
                        actionListener="#{commentController.chunking}">

                </h:commandLink>
            </ui:repeat>
        </h:form>
    </div>
    <h:form>
        <h:outputText value="#{commentBundle.commentFormTitle}" styleClass="commentFormTitle"/>
        <div class="commentForm" >
            <!-- This will be the comment form -->
            <h:panelGrid columns="2" columnClasses="commentFormElement">
                <h:outputLabel for="strUserName" accesskey="N">
                    <h:outputText styleClass="mainPanelLabel" value="#{commentBundle.userName}:"/>
                </h:outputLabel>
                <h:panelGroup style="display:inline;">
                    <h:inputText id="strUserName" size="55" value="#{commentController.userName}"
                                 required="true" styleClass="mainPanelField">
                        <f:validateLength minimum="2" maximum="50"/>
                    </h:inputText>
                    <f:verbatim><br/></f:verbatim>
                    <h:message for="strUserName" styleClass="error"/>
                </h:panelGroup>

                <h:outputLabel for="strEmail">
                    <h:outputText styleClass="mainPanelLabel" value="#{commentBundle.email}:"/>
                </h:outputLabel>
                <h:panelGroup style="display:inline;">
                    <h:inputText id="strEmail" size="55" value="#{commentController.email}"
                                 required="true" styleClass="mainPanelField">
                        <f:validateLength minimum="5" maximum="50"/>
                    </h:inputText>
                    <f:verbatim><br/></f:verbatim>
                    <h:message for="strEmail" styleClass="error"/>
                </h:panelGroup>

                <h:outputLabel for="strMessage">
                    <h:outputText styleClass="mainPanelLabel" value="#{commentBundle.message}:"/>
                </h:outputLabel>
                <h:panelGroup style="display:inline;">
                    <h:inputTextarea id="strMessage" value="#{commentController.message}"
                                     required="true" cols="55" rows="7" styleClass="mainPanelField">
                        <f:validateLength minimum="1" maximum="10000"/>
                    </h:inputTextarea>
                    <f:verbatim><br/></f:verbatim>
                    <h:message for="strMessage" styleClass="error"/>
                </h:panelGroup>

            </h:panelGrid>

            <div id="button" class="commentButton">
                <h:commandLink value="#{commentBundle.send}"
                               action="#{commentController.sendComment}"
                               styleClass="mainPanelButton"
                        />
            </div>

        </div>
    </h:form>
</div>

<h:form>
    <div class="mainPanelInfo">

        <h:commandLink class="mainPanelLink"
                       value="#{contactBundle.imageProcessingLink}"
                       action="image_processing"/>

    </div>
</h:form>

</div>
</h:panelGroup>

</f:subview>
</ui:composition>

</jsp:root>